package leetcode;

/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2554.java
 * @Author : WangRuoyu
 * @Date 2023/2/20 16:06
 */
public class Q2554 {
    public int maxCount(int[] banned, int n, int maxSum) {
        int res = 0;
        int[] nums = new int[10001];
        for (int num : banned) {
            nums[num] = -1;
        }
        for (int i = 1; i <= n; ++i) {
            if (maxSum < i) {
                break;
            } else {
                if (nums[i] != -1) {
                    res++;
                    maxSum -= i;
                }
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Q2554 sl = new Q2554();
        int[] banned = {1, 6, 5};
        int n = 5;
        int maxSum = 6;
        System.out.println(sl.maxCount(banned, n, maxSum));
    }
}